{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js,jquery-1.7.2.min.js"}
<script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<style>
			#tooltip{
				position:absolute;
				border:1px solid #ccc;
				background:#333;
				padding:2px;
				display:none;
				color:#fff;
			}
</style>
<!-- 商品搜索 -->
<div class="form-div">
  <form action="javascript:searchNews()" name="searchForm" >
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
	
	{$lang.create_time}
	<input name="start_time" onclick="return showCalendar('start_time', '%Y-%m-%d %H:%M', '24', false, 'start_time');" type="text" id="start_time" size="22" value='{$start_time}' readonly="readonly" />
	{$lang.zhi}
	<input name="end_time" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M', '24', false, 'end_time');" type="text" id="end_time" size="22" value='{$end_time}' readonly="readonly" />
    
	<br/>
	<br/>
	{$lang.circle_name} 
	<select name="circle_id">
		<option value="">--- ---</option>
		{foreach from=$circle_select item=circle}
			<option value="{$circle.id}">{$circle.circle_name}</option>
		{/foreach} 
	</select>
	{$lang.audit_status}
	<select name="audit_status">
		<option value="">-- --</option>
		<option value="1">未审核</option>
		<option value="2">审核通过</option>
		<option value="3">审核不通过</option>
	</select>
	{$lang.creater}
	<input name="creater" type="text" id="creater" size="22" value='{$creater}'/>
	
    <input type="submit" value="{$lang.button_search}" class="button" />
  </form>
</div>
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
{/if}
<table cellpadding="3" cellspacing="1">
  <tr>
    <!--<th>
      <input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" />
      <a href="javascript:listTable.sort('id'); ">{$lang.record_id}</a>{$sort_id}
    </th>-->
    <th>{$lang.title}</th>
    <th>{$lang.circle_name}</th>
    <th>{$lang.creater}</th>
    <th >{$lang.content}</th>
    <th>{$lang.news_img}</th>
    <th><a href="javascript:listTable.sort('create_time'); ">{$lang.create_time}</a>{$sort_create_time}</th>
    <th>{$lang.audit_status}</th>
    <th>{$lang.is_top}</th>
    <th>{$lang.sort_order}</th>
    <th>点赞/评论/收藏</th>
    <th>{$lang.handler}</th>
  <tr>
  {foreach from=$news_list item=news}
  <tr>
    <!--<td align="left"><input type="checkbox" name="checkboxes[]" value="{$circle.id}" />{$circle.id}</td>-->
    <td class="first-cell">
    	<span onclick="javascript:listTable.edit(this, 'edit_title', {$news.id})">{$news.title|default:暂无}</span>
    	
	</td>
    <td >
    	<select name="circle_id" onChange="changeCircle(this,{$news.id})">
			<option value="" >---</option>
			{foreach from=$circle_select item=circle}
				<option value="{$circle.id}"  {if $news.circle_id eq $circle.id}selected="selected"{/if} >{$circle.circle_name}</option>
			{/foreach} 
		</select>
	</td>
	<td align="center">{$news.nickname}</td>
    <td  style="max-width:100px" align="left">{$news.content}</td>
	<td align="center">
		{foreach from=$news.img item=pic}
			<a href="/chunle{$pic.thumb}" class="tooltip" ><img src="/chunle{$pic.thumb}"  style="width:30px;"></a>
		{/foreach}
		
	</td>
    <td align="center">{$news.create_time}</td>
	<td align="center">{$news.audit_status_show}</td>
	<td align="center"><img src="images/{if $news.is_top}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_is_top', {$news.id})" /></td>
	<td class="center">
    	<span onclick="javascript:listTable.edit(this, 'edit_order', {$news.id})">{$news.sort_order|default:0}</span>
    	
	</td>
	<td align="center">{$news.like_num}/{$news.comment_num}/{$news.collect_times}</td>
    <td align="center">
      {if $news.audit_status eq '1'}
      <a onClick="audit({$news.id},2)" href="javascript:;" >{$lang.audit_pass}</a>|
      <a onClick="audit({$news.id},3)" href="javascript:;" >{$lang.audit_nopass}</a>
	  {elseif $news.audit_status eq '2'}
      <a onClick="audit({$news.id},3)" href="javascript:;" >{$lang.audit_nopass}</a>
	  {elseif $news.audit_status eq '3'}
      <a onClick="audit({$news.id},2)" href="javascript:;" >{$lang.audit_pass}</a>
      {/if}
	  |
      <a href="javascript:;" onclick="listTable.remove({$news.id}, '{$lang.drop_confirm}')" title="{$lang.remove}">{$lang.remove}</a>
	  |
      <a href="news_comment.php?act=list&amp;news_id={$news.id}" >{$lang.comment}</a>
    </td>
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
</table>
<!-- end goods list -->
<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    {include file="page.htm"}
    </td>
  </tr>
</table>
{if $full_page}
</div>
</form>
<script>
	listTable.recordCount = {$record_count};
	listTable.pageCount = {$page_count};
	
	{foreach from=$filter item=item key=key}
	listTable.filter.{$key} = '{$item}';
	{/foreach}
/* 搜索文章 */
 function searchNews()
 {
    listTable.filter.circle_id = Utils.trim(document.forms['searchForm'].elements['circle_id'].value);
    listTable.filter.audit_status = Utils.trim(document.forms['searchForm'].elements['audit_status'].value);
    listTable.filter.start_time = Utils.trim(document.forms['searchForm'].elements['start_time'].value);
    listTable.filter.end_time = Utils.trim(document.forms['searchForm'].elements['end_time'].value);
    listTable.filter.creater = Utils.trim(document.forms['searchForm'].elements['creater'].value);
    listTable.filter.page = 1;
    listTable.loadList();
	tool();
 }
 function audit(id,audit_status){
 	var url = "news.php?act=audit&id="+id+"&audit_status="+audit_status;
 	Ajax.call(url, "",function(result){
		if (result.error > 0)
		  {
		    alert(result.message);
		  }
		  else
		  {
		  	$(".button").eq(0).click();
		  }
	}, "GET", "JSON");
 }
 function tool(){
 	var x = 10;
	var y = 20;
	$("a.tooltip").mouseover(function(e){
		this.myTitle = this.title;
		this.title = "";
		var imgTitle = this.myTitle? "<br/>" + this.myTitle : "";
		var tooltip = "<div id='tooltip'><img style='max-width:250px;' src='"+ this.href +"' alt='产品预览图'/>"+imgTitle+"<\/div>"; //创建 div 元素
		$("body").append(tooltip);	//把它追加到文档中
//		$("#tooltip")
//			.css({
//				"top": (e.pageY+y) + "px",
//				"left":  (e.pageX+x)  + "px"
//			});
	document.getElementById("tooltip").style.top = (e.pageY+y) + "px";
	document.getElementById("tooltip").style.left = (e.pageX+x)  + "px";
	document.getElementById("tooltip").style.display = "block";
//		.show("fast");	  //设置x坐标和y坐标，并且显示
    }).mouseout(function(){
		this.title = this.myTitle;
		$("#tooltip").remove();	 //移除
    }).mousemove(function(e){
		document.getElementById("tooltip").style.top = (e.pageY+y) + "px";
		document.getElementById("tooltip").style.left = (e.pageX+x)  + "px";
	});
 }
 $(function(){
	tool();
})
function  callbackAjax(){
 	tool();
 }
 
 function changeCircle(params,id){
	var val=$(params).find("option:selected").val();
	var url = "news.php?act=editCircle";
	var data = {
		id:id,
		circle_id:val
	}
	res = Ajax.call(url, "id="+id+"&circle_id=" + val , null, "POST", "JSON", false);
	if (res.message)
    alert(res.message);
 }
</script>
{include file="pagefooter.htm"}
{/if}
